package com.naiterui.ehp.bs.emr.controller.inner;

import com.naiterui.ehp.bp.bo.smh.SmhUserBO;
import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.constants.SwaggerTags;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.emr.service.ISmhService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 就诊记录
 *
 * @author guoyongxiang
 * @version 1.0.0
 * @date 2021/8/13 15:18
 **/
@Slf4j
@Api(tags = SwaggerTag.PATIENT + SwaggerTag.INNER_API + SwaggerTag.MEDICAL_RECORD)
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("emr/inner/patient/smh/case")
public class EmrInnerPatientSmhController {

    private final ISmhService smhService;

    @ApiOperation(value = "根据身份证号姓名获取患者HIS就诊记录", notes = "根据身份证号获取患者HIS就诊记录", tags = SwaggerTags.WX_PATIENT_CASE)
    @ApiImplicitParams({@ApiImplicitParam(name = "inquirerMap", value = "身份证号姓名map", required = true,
            dataType = "string", paramType = "body"),})
    @PostMapping("records")
    public ResponseVO<List<SmhUserBO>> getPatientRecords(@RequestBody Map<String, String> inquirerMap)
            throws BusinessException {
        log.info("根据身份证号和姓名获取患者HIS就诊记录 inquirerMap:{}", inquirerMap);
        List<SmhUserBO> users = smhService.getPatientListByIds(inquirerMap);
        return PublicService.returnResponseVO(users);
    }
}
